<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"> <style>
	.KEYW {color: #933;}
	.COMM {color: #bbb; font-style: italic;}
	.NUMB {color: #393;}
	.STRN {color: #393;}
	.REGX {color: #339;}
	.line {border-right: 1px dotted #666; color: #666; font-style: normal;}
	</style></head><body><pre><span class='line'>  1</span> <span class="COMM">/*
<span class='line'>  2</span>  * Licensed to the Apache Software Foundation (ASF) under one
<span class='line'>  3</span>  * or more contributor license agreements.  See the NOTICE file
<span class='line'>  4</span>  * distributed with this work for additional information
<span class='line'>  5</span>  * regarding copyright ownership.  The ASF licenses this file
<span class='line'>  6</span>  * to you under the Apache License, Version 2.0 (the
<span class='line'>  7</span>  * "License"); you may not use this file except in compliance
<span class='line'>  8</span>  * with the License.  You may obtain a copy of the License at
<span class='line'>  9</span>  *
<span class='line'> 10</span>  *     http://www.apache.org/licenses/LICENSE-2.0
<span class='line'> 11</span>  *
<span class='line'> 12</span>  * Unless required by applicable law or agreed to in writing,
<span class='line'> 13</span>  * software distributed under the License is distributed on an
<span class='line'> 14</span>  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
<span class='line'> 15</span>  * KIND, either express or implied.  See the License for the
<span class='line'> 16</span>  * specific language governing permissions and limitations
<span class='line'> 17</span>  * under the License.
<span class='line'> 18</span>  */</span><span class="WHIT">
<span class='line'> 19</span> 
<span class='line'> 20</span> </span><span class="COMM">/**
<span class='line'> 21</span>  * @fileoverview A wrapper library for opensocial javascript API into actionscript.
<span class='line'> 22</span>  * &lt;p>
<span class='line'> 23</span>  * It works with the Opensocial AS3 Client Library. In this file, it communicates between
<span class='line'> 24</span>  * swf functions and the gadgets/opensocial javascript API functions.
<span class='line'> 25</span>  * &lt;/p>
<span class='line'> 26</span>  * &lt;p>
<span class='line'> 27</span>  * TODO: 1. Provide a compiled javascript file.
<span class='line'> 28</span>  *       2. Support batch in next version.
<span class='line'> 29</span>  * &lt;/p>
<span class='line'> 30</span>  *
<span class='line'> 31</span>  * @see &lt;a href="http://code.google.com/apis/opensocial/docs/0.8/reference/">Opensocial 0.8 Reference&lt;/a>
<span class='line'> 32</span>  * @see &lt;a href="http://www.opensocial.org/Technical-Resources/opensocial-spec-v09/OpenSocial-Specification.html#LightweightJSAPI">Opensocial 0.9 Lightweight JSAPI&lt;/a>
<span class='line'> 33</span>  * @version M4
<span class='line'> 34</span>  * @author yiziwu@google.com (Yizi Wu)
<span class='line'> 35</span>  */</span><span class="WHIT">
<span class='line'> 36</span> 
<span class='line'> 37</span> </span><span class="COMM">//======================== External Namespace and Flags ==================================</span><span class="WHIT">
<span class='line'> 38</span> </span><span class="COMM">/**
<span class='line'> 39</span>  * External namespace for &lt;code>gadgets&lt;/code> for internal reference.
<span class='line'> 40</span>  * @static
<span class='line'> 41</span>  * @name gadgets
<span class='line'> 42</span>  * @see &lt;a href="http://opensocial-resources.googlecode.com/svn/spec/0.8/gadgets/">Gadgets Spec&lt;/a>
<span class='line'> 43</span>  */</span><span class="WHIT">
<span class='line'> 44</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">gadgets</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">'gadgets'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 45</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">gadgets</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 46</span> </span><span class="WHIT">  </span><span class="NAME">alert</span><span class="PUNC">(</span><span class="STRN">'gadgets.* not found.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 47</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 48</span> 
<span class='line'> 49</span> 
<span class='line'> 50</span> </span><span class="COMM">/**
<span class='line'> 51</span>  * External namespace for &lt;code>opensocial&lt;/code> for internal reference.
<span class='line'> 52</span>  * @static
<span class='line'> 53</span>  * @name opensocial
<span class='line'> 54</span>  * @see &lt;a href="http://opensocial-resources.googlecode.com/svn/spec/0.8/opensocial/">Opensocial Spec&lt;/a>
<span class='line'> 55</span>  */</span><span class="WHIT">
<span class='line'> 56</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">opensocial</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">'opensocial'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 57</span> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">opensocial</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 58</span> </span><span class="WHIT">  </span><span class="NAME">alert</span><span class="PUNC">(</span><span class="STRN">'opensocial.* not found.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 59</span> </span><span class="WHIT">  </span><span class="NAME">opensocial</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 60</span> </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'> 61</span> 
<span class='line'> 62</span> </span><span class="COMM">/**
<span class='line'> 63</span>  * Flag for release version or testing version. Set to true before loading this script to get the
<span class='line'> 64</span>  * testbed object to run the jsunit tests.
<span class='line'> 65</span>  * @static
<span class='line'> 66</span>  * @type {boolean}
<span class='line'> 67</span>  * @ignore
<span class='line'> 68</span>  */</span><span class="WHIT">
<span class='line'> 69</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">TESTING</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TESTING</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 70</span> 
<span class='line'> 71</span> </span><span class="COMM">/**
<span class='line'> 72</span>  * Flag for release version or debug version. Set to true to get debug info on firebug console.
<span class='line'> 73</span>  * @static
<span class='line'> 74</span>  * @type {boolean}
<span class='line'> 75</span>  * @ignore
<span class='line'> 76</span>  */</span><span class="WHIT">
<span class='line'> 77</span> </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">DEBUG</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">TESTING</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">DEBUG</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'> 78</span> 
<span class='line'> 79</span> 
<span class='line'> 80</span> 
<span class='line'> 81</span> </span><span class="COMM">//======================== Opensocial Flash Namespace ==================================</span><span class="WHIT">
<span class='line'> 82</span> </span><span class="COMM">/**
<span class='line'> 83</span>  * Namespace for top-level api functions
<span class='line'> 84</span>  * @static
<span class='line'> 85</span>  * @namespace Namespace for top-level api functions.
<span class='line'> 86</span>  * @requires opensocial
<span class='line'> 87</span>  * @requires gadgets
<span class='line'> 88</span>  * @name opensocial.flash
<span class='line'> 89</span>  */</span><span class="WHIT">
<span class='line'> 90</span> </span><span class="NAME">opensocial.flash</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'> 91</span> 
<span class='line'> 92</span> </span><span class="WHIT">  </span><span class="COMM">//======================== Debugging Tools (private) ===========================================</span><span class="WHIT">
<span class='line'> 93</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'> 94</span>    * For debugging, return the object's keys and values.
<span class='line'> 95</span>    * @param {Object?} obj Any object to be looked into.
<span class='line'> 96</span>    * @param {string?} opt_prefix The prefix string of each output line.
<span class='line'> 97</span>    * @param {string?} opt_rendered The rendered string passing between recursions.
<span class='line'> 98</span>    * @return {string?} A tree-style string to represent the object.
<span class='line'> 99</span>    * @private
<span class='line'>100</span>    */</span><span class="WHIT">
<span class='line'>101</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">INSPECT</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_prefix</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_rendered</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>102</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">opt_rendered</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">opt_rendered</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'\n'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>103</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">opt_prefix</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">opt_prefix</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">''</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>104</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opt_rendered</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>105</span> </span><span class="WHIT">    </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>106</span> </span><span class="WHIT">      </span><span class="NAME">opt_rendered</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT">
<span class='line'>107</span> </span><span class="WHIT">          </span><span class="PUNC">(</span><span class="NAME">opt_prefix</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'['</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'] : '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\n'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>108</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>109</span> </span><span class="WHIT">        </span><span class="NAME">opt_rendered</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">INSPECT</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_prefix</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'\t'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_rendered</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>110</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>111</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>112</span> </span><span class="WHIT">    </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opt_rendered</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>113</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>114</span> 
<span class='line'>115</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>116</span>    * For debugging, export the local variables to global.
<span class='line'>117</span>    * Only available when DEBUG = true.
<span class='line'>118</span>    * @param {string} name The nathis.
<span class='line'>119</span>    * @param {Object?} value The value.
<span class='line'>120</span>    * @private
<span class='line'>121</span>    */</span><span class="WHIT">
<span class='line'>122</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">EXPORT</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">name</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>123</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">DEBUG</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">opensocial.flash</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>124</span> </span><span class="WHIT">      </span><span class="NAME">opensocial.flash</span><span class="PUNC">[</span><span class="STRN">'export'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.flash</span><span class="PUNC">[</span><span class="STRN">'export'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>125</span> </span><span class="WHIT">      </span><span class="NAME">opensocial.flash</span><span class="PUNC">[</span><span class="STRN">'export'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">name</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>126</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>127</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>128</span> 
<span class='line'>129</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>130</span>    * For debugging, output text information to firebug console.
<span class='line'>131</span>    * Only available when DEBUG = true.
<span class='line'>132</span>    * @param {Object?} content The content to be logged.
<span class='line'>133</span>    * @private
<span class='line'>134</span>    */</span><span class="WHIT">
<span class='line'>135</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">INFO</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">content</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>136</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">DEBUG</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">window.console</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>137</span> </span><span class="WHIT">      </span><span class="NAME">window.console.info</span><span class="PUNC">(</span><span class="NAME">content</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>138</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>139</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>140</span> 
<span class='line'>141</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>142</span>    * For debugging, log the object to firebug console.
<span class='line'>143</span>    * Only available when DEBUG = true.
<span class='line'>144</span>    * @param {Object?} content The content to be logged.
<span class='line'>145</span>    * @private
<span class='line'>146</span>    */</span><span class="WHIT">
<span class='line'>147</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">LOG</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">content</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>148</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">DEBUG</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">window.console</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>149</span> </span><span class="WHIT">      </span><span class="NAME">window.console.log</span><span class="PUNC">(</span><span class="NAME">content</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>150</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>151</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>152</span> 
<span class='line'>153</span> </span><span class="WHIT">  </span><span class="COMM">// Export these debugging functions for shortcuts</span><span class="WHIT">
<span class='line'>154</span> </span><span class="WHIT">  </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">DEBUG</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>155</span> </span><span class="WHIT">    </span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">"INFO"</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">INFO</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>156</span> </span><span class="WHIT">    </span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">"LOG"</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">LOG</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>157</span> </span><span class="WHIT">    </span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">"INSPECT"</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">INSPECT</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>158</span> </span><span class="WHIT">    </span><span class="NAME">window</span><span class="PUNC">[</span><span class="STRN">"EXPORT"</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">EXPORT</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>159</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>160</span> 
<span class='line'>161</span> 
<span class='line'>162</span> </span><span class="WHIT">  </span><span class="COMM">//======================== Kernel Object (private) =============================================</span><span class="WHIT">
<span class='line'>163</span> 
<span class='line'>164</span> </span><span class="WHIT">  </span><span class="COMM">/**
<span class='line'>165</span>    * The underlying object holds all variables and functions for the opensocial.flash module.
<span class='line'>166</span>    * @type {Object}
<span class='line'>167</span>    * @private
<span class='line'>168</span>    */</span><span class="WHIT">
<span class='line'>169</span> </span><span class="WHIT">  </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">kernel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>170</span> 
<span class='line'>171</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>172</span>      * Alias for 'this' to avoid misusing the 'this' reference in difference scopes or closures.
<span class='line'>173</span>      * @type {Object}
<span class='line'>174</span>      * @private;
<span class='line'>175</span>      */</span><span class="WHIT">
<span class='line'>176</span> </span><span class="WHIT">    </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">me</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">this</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>177</span> 
<span class='line'>178</span> 
<span class='line'>179</span> </span><span class="WHIT">    </span><span class="COMM">//======================== Flash Embeded Object Varibles (private) ===========================</span><span class="WHIT">
<span class='line'>180</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>181</span>      * The flash movie object which apply this API.
<span class='line'>182</span>      * This object is initialized in &lt;code>opensocial.flash.jsReady&lt;/code> function.
<span class='line'>183</span>      * @type {HTMLElement}
<span class='line'>184</span>      * @private
<span class='line'>185</span>      */</span><span class="WHIT">
<span class='line'>186</span> </span><span class="WHIT">    </span><span class="NAME">me.swfObj</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>187</span> 
<span class='line'>188</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>189</span>      * The default flash id embeded in container.
<span class='line'>190</span>      * @type {string}
<span class='line'>191</span>      * @constant
<span class='line'>192</span>      * @private
<span class='line'>193</span>      */</span><span class="WHIT">
<span class='line'>194</span> </span><span class="WHIT">    </span><span class="NAME">me.DEFAULT_FLASH_ID</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"flashObj"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>195</span> 
<span class='line'>196</span> 
<span class='line'>197</span> </span><span class="WHIT">    </span><span class="COMM">//======================== Common Utilities Helper Functions (private) =========================</span><span class="WHIT">
<span class='line'>198</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>199</span>      * Returns the document object.
<span class='line'>200</span>      * @return {HTMLDocument} the document object of current context.
<span class='line'>201</span>      * @private
<span class='line'>202</span>      */</span><span class="WHIT">
<span class='line'>203</span> </span><span class="WHIT">    </span><span class="NAME">me.thisDoc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>204</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">document</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>205</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>206</span> 
<span class='line'>207</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>208</span>      * Returns the window object.
<span class='line'>209</span>      * @return {Window} the window object of current context.
<span class='line'>210</span>      * @private
<span class='line'>211</span>      */</span><span class="WHIT">
<span class='line'>212</span> </span><span class="WHIT">    </span><span class="NAME">me.thisWin</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>213</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">window</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>214</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>215</span> 
<span class='line'>216</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>217</span>      * Returns the navigator object.
<span class='line'>218</span>      * @return {Navigator} the navigator object of current context.
<span class='line'>219</span>      * @private
<span class='line'>220</span>      */</span><span class="WHIT">
<span class='line'>221</span> </span><span class="WHIT">    </span><span class="NAME">me.thisBrowser</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>222</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">navigator</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>223</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>224</span> 
<span class='line'>225</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>226</span>      * Gets the swf object.
<span class='line'>227</span>      * @param {string?} opt_name The object/embed tag's id or name
<span class='line'>228</span>      * @return {HTMLElement} the swf object.
<span class='line'>229</span>      * @private
<span class='line'>230</span>      */</span><span class="WHIT">
<span class='line'>231</span> </span><span class="WHIT">    </span><span class="NAME">me.thisMovie</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">opt_name</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>232</span> </span><span class="WHIT">      </span><span class="NAME">opt_name</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_name</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">me.DEFAULT_FLASH_ID</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>233</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="NAME">me.thisBrowser</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">appName.indexOf</span><span class="PUNC">(</span><span class="STRN">'Microsoft'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="PUNC">-</span><span class="NUMB">1</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>234</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">me.thisDoc</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">[</span><span class="NAME">opt_name</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>235</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>236</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">me.thisDoc</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getElementById</span><span class="PUNC">(</span><span class="NAME">opt_name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>237</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>238</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>239</span> 
<span class='line'>240</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>241</span>      * Checks if the object is an array.
<span class='line'>242</span>      * @param {Object} obj object to be check.
<span class='line'>243</span>      * @return {boolean} True if the object is an array.
<span class='line'>244</span>      * @private
<span class='line'>245</span>      */</span><span class="WHIT">
<span class='line'>246</span> </span><span class="WHIT">    </span><span class="NAME">me.isArray</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>247</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>248</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">Array</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>249</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">Array</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>250</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>251</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>252</span> </span><span class="WHIT">            </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj.length</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>253</span> </span><span class="WHIT">            </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj.splice</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'undefined'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>254</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>255</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>256</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>257</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>258</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>259</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>260</span> 
<span class='line'>261</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>262</span>      * Iterates an array, calls the function for each item.
<span class='line'>263</span>      * @param {Array} array The array to be iterated.
<span class='line'>264</span>      * @param {Function} f The function to be applied.
<span class='line'>265</span>      * @param {Object} opt_thisObj The this object for the function.
<span class='line'>266</span>      * @private
<span class='line'>267</span>      */</span><span class="WHIT">
<span class='line'>268</span> </span><span class="WHIT">    </span><span class="NAME">me.forEach</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">array</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">f</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_thisObj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>269</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">array.length</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="STRN">'number'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>270</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>271</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>272</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">l</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">array.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>273</span> </span><span class="WHIT">      </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">l</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">++</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>274</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">i</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">array</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>275</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">false</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">f.call</span><span class="PUNC">(</span><span class="NAME">opt_thisObj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">array</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">i</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">array</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>276</span> </span><span class="WHIT">            </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>277</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>278</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>279</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>280</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>281</span> 
<span class='line'>282</span> 
<span class='line'>283</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>284</span>      * Deeply clones an non-native object.
<span class='line'>285</span>      * @param {Object?} obj The original object.
<span class='line'>286</span>      * @return {Object?} The cloned object.
<span class='line'>287</span>      * @private
<span class='line'>288</span>      */</span><span class="WHIT">
<span class='line'>289</span> </span><span class="WHIT">    </span><span class="NAME">me.clone</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>290</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>291</span> </span><span class="WHIT">      </span><span class="KEYW">switch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">typeof</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>292</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'function'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>293</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>294</span> </span><span class="WHIT">        </span><span class="KEYW">case</span><span class="WHIT"> </span><span class="STRN">'object'</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>295</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">newObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">obj.constructor</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>296</span> </span><span class="WHIT">          </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="NAME">newObj</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.clone</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>297</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">newObj</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>298</span> </span><span class="WHIT">        </span><span class="KEYW">default</span><span class="PUNC">:</span><span class="WHIT">
<span class='line'>299</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">obj.valueOf</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>300</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>301</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>302</span> 
<span class='line'>303</span> </span><span class="WHIT">    </span><span class="COMM">//======================== Opensocial Data Helper Functions (private) ==========================</span><span class="WHIT">
<span class='line'>304</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>305</span>      * Gets data object from resoponse.
<span class='line'>306</span>      * @param {opensocial.DataResponse} dataResponse The response object.
<span class='line'>307</span>      * @param {string} key The data key in the response object.
<span class='line'>308</span>      * @throws {Error} When the RPC meets error.
<span class='line'>309</span>      * @return {Object?} The data, can be any instance of the opensocial.* data type.
<span class='line'>310</span>      * @private
<span class='line'>311</span>      */</span><span class="WHIT">
<span class='line'>312</span> </span><span class="WHIT">    </span><span class="NAME">me.getData</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>313</span> </span><span class="WHIT">      </span><span class="COMM">// for debug</span><span class="WHIT">
<span class='line'>314</span> </span><span class="WHIT">      </span><span class="NAME">EXPORT</span><span class="PUNC">(</span><span class="STRN">'DATA_RESPONSE'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="STRN">'key'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'data'</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">dataResponse</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>315</span> 
<span class='line'>316</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">dataResponse</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>317</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">dataResponse.hadError</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>318</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NAME">dataResponse.getErrorMessage</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>319</span> </span><span class="WHIT">        </span><span class="NAME">e</span><span class="PUNC">[</span><span class="STRN">'name'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"OpensocialError"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>320</span> </span><span class="WHIT">        </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>321</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>322</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">key</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>323</span> 
<span class='line'>324</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">me.getDataItem</span><span class="PUNC">(</span><span class="NAME">dataResponse.get</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>325</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>326</span> 
<span class='line'>327</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>328</span>      * Gets data object from response item.
<span class='line'>329</span>      * @param {opensocial.ResponseItem} responseItem The response item object.
<span class='line'>330</span>      * @throws {Error} When the items have errors.
<span class='line'>331</span>      * @return {Object?} The data, can be any instance of the opensocial.* data type.
<span class='line'>332</span>      * @private
<span class='line'>333</span>      */</span><span class="WHIT">
<span class='line'>334</span> </span><span class="WHIT">    </span><span class="NAME">me.getDataItem</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>335</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>336</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">responseItem.hadError</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>337</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="NAME">responseItem.getErrorMessage</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>338</span> </span><span class="WHIT">        </span><span class="NAME">e</span><span class="PUNC">[</span><span class="STRN">'name'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"OpensocialError"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>339</span> </span><span class="WHIT">        </span><span class="NAME">e</span><span class="PUNC">[</span><span class="STRN">'code'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">responseItem.getErrorCode</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>340</span> </span><span class="WHIT">        </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>341</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>342</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">responseItem.getData</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>343</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>344</span> 
<span class='line'>345</span> </span><span class="WHIT">    </span><span class="NAME">me.dataTypes</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="STRN">'Address'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'BodyType'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Email'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Name'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Organization'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Phone'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Url'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>346</span> </span><span class="WHIT">        </span><span class="STRN">'Enum'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Person'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Activity'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'IdSpec'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'MediaItem'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'Message'</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'NavigationParameters'</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>347</span> </span><span class="WHIT">        </span><span class="STRN">'Collection'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>348</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>349</span>      * Gets the constructor function for opensocial data object.
<span class='line'>350</span>      * @param {Object} dataObj The object to be checked.
<span class='line'>351</span>      * @return {Function?} The type of the object.
<span class='line'>352</span>      * @private
<span class='line'>353</span>      */</span><span class="WHIT">
<span class='line'>354</span> </span><span class="WHIT">    </span><span class="NAME">me.checkType</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataObj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>355</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">dataObj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>356</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>357</span> </span><span class="WHIT">      </span><span class="NAME">me.forEach</span><span class="PUNC">(</span><span class="NAME">me.dataTypes</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">typeItem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>358</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">typeItem</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">opensocial</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">dataObj</span><span class="WHIT"> </span><span class="KEYW">instanceof</span><span class="WHIT"> </span><span class="NAME">opensocial</span><span class="PUNC">[</span><span class="NAME">typeItem</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>359</span> </span><span class="WHIT">          </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial</span><span class="PUNC">[</span><span class="NAME">typeItem</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>360</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>361</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>362</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>363</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>364</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>365</span> 
<span class='line'>366</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>367</span>      * Wraps the opensocial rich object (with functions) to a JSON-like flat serializable object.
<span class='line'>368</span>      * So the object can pass through the &lt;code>ExternalInterface&lt;/code> to the swf.
<span class='line'>369</span>      * @param {Object} dataObj The object to be wrapped.
<span class='line'>370</span>      * @param {Object?} opt_this The flat object as a container to hold the wrapped fields.
<span class='line'>371</span>      * @return {Object?} A wrapped flat object, ready to pass to swf.
<span class='line'>372</span>      * @private
<span class='line'>373</span>      */</span><span class="WHIT">
<span class='line'>374</span> </span><span class="WHIT">    </span><span class="NAME">me.wrapObject</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataObj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_this</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>375</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">dataObj</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>376</span> 
<span class='line'>377</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.checkType</span><span class="PUNC">(</span><span class="NAME">dataObj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>378</span> 
<span class='line'>379</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>380</span> </span><span class="WHIT">        </span><span class="COMM">// treat it as string</span><span class="WHIT">
<span class='line'>381</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">dataObj</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>382</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>383</span> 
<span class='line'>384</span> </span><span class="WHIT">      </span><span class="COMM">// fix fields</span><span class="WHIT">
<span class='line'>385</span> </span><span class="WHIT">      </span><span class="NAME">opt_this</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_this</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>386</span> 
<span class='line'>387</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="STRN">'Field'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>388</span> </span><span class="WHIT">        </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'fields'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'fields'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>389</span> 
<span class='line'>390</span> </span><span class="WHIT">        </span><span class="COMM">// Grabs the fields data from each structures recursively.</span><span class="WHIT">
<span class='line'>391</span> </span><span class="WHIT">        </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">k</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">type.Field</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>392</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">type.Field</span><span class="PUNC">[</span><span class="NAME">k</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>393</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.getField</span><span class="PUNC">(</span><span class="NAME">key</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>394</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>395</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">me.isArray</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>396</span> </span><span class="WHIT">              </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'fields'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>397</span> </span><span class="WHIT">              </span><span class="NAME">me.forEach</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>398</span> </span><span class="WHIT">                </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'fields'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">me.wrapObject</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>399</span> </span><span class="WHIT">              </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>400</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>401</span> </span><span class="WHIT">              </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'fields'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.wrapObject</span><span class="PUNC">(</span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>402</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>403</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>404</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>405</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>406</span> 
<span class='line'>407</span> </span><span class="WHIT">      </span><span class="COMM">// fix properties.</span><span class="WHIT">
<span class='line'>408</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.Person</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>409</span> </span><span class="WHIT">        </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'displayName'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.getDisplayName</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>410</span> </span><span class="WHIT">        </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'isOwner'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.isOwner</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>411</span> </span><span class="WHIT">        </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'isViewer'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.isViewer</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>412</span> </span><span class="WHIT">        </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'id'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.getId</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>413</span> 
<span class='line'>414</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.Activity</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>415</span> </span><span class="WHIT">        </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'id'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.getId</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>416</span> 
<span class='line'>417</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.Enum</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>418</span> </span><span class="WHIT">        </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'key'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.getKey</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>419</span> </span><span class="WHIT">        </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'displayValue'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.getDisplayValue</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>420</span> 
<span class='line'>421</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.Collection</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>422</span> </span><span class="WHIT">        </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'size'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.size</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>423</span> </span><span class="WHIT">        </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'offset'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.getOffset</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>424</span> </span><span class="WHIT">        </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'totalSize'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.getTotalSize</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>425</span> 
<span class='line'>426</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">array</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">dataObj.asArray</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>427</span> </span><span class="WHIT">        </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'array'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>428</span> </span><span class="WHIT">        </span><span class="NAME">me.forEach</span><span class="PUNC">(</span><span class="NAME">array</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>429</span> </span><span class="WHIT">          </span><span class="NAME">opt_this</span><span class="PUNC">[</span><span class="STRN">'array'</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">push</span><span class="PUNC">(</span><span class="NAME">me.wrapObject</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>430</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>431</span> 
<span class='line'>432</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>433</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opt_this</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>434</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>435</span> 
<span class='line'>436</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>437</span>      * Unwraps the flattened object to a rich opensocial data object. The flattened object is come
<span class='line'>438</span>      * from the swf via &lt;code>ExternalInterface&lt;/code>.
<span class='line'>439</span>      * @param {Object} obj The object to be unwrapped. Only those 5 types with &lt;code>setField&lt;/code>
<span class='line'>440</span>      *                 method and &lt;code>opensocial.newXXXX&lt;/code> creator can be unwrapped.
<span class='line'>441</span>      * @param {Function} type The object's target type to be unwrapped.
<span class='line'>442</span>      * @throws {Error} When the type is not correct.
<span class='line'>443</span>      * @return {Object} Unwrapped rich opensocial data object, ready to use in javascript.
<span class='line'>444</span>      * @private
<span class='line'>445</span>      */</span><span class="WHIT">
<span class='line'>446</span> </span><span class="WHIT">    </span><span class="NAME">me.unwrapObject</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">type</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>447</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">obj</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="STRN">'fields'</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>448</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fields</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">[</span><span class="STRN">'fields'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>449</span> 
<span class='line'>450</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.IdSpec</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>451</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opensocial.newIdSpec</span><span class="PUNC">(</span><span class="NAME">fields</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>452</span> 
<span class='line'>453</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.NavigationParameters</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>454</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opensocial.newNavigationParameters</span><span class="PUNC">(</span><span class="NAME">fields</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>455</span> 
<span class='line'>456</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.MediaItem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>457</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opensocial.newMediaItem</span><span class="PUNC">(</span><span class="NAME">fields</span><span class="PUNC">[</span><span class="NAME">opensocial.MediaItem.Field.MIME_TYPE</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>458</span> </span><span class="WHIT">                                         </span><span class="NAME">fields</span><span class="PUNC">[</span><span class="NAME">opensocial.MediaItem.Field.URL</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>459</span> </span><span class="WHIT">                                         </span><span class="NAME">fields</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>460</span> 
<span class='line'>461</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.Message</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>462</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opensocial.newMessage</span><span class="PUNC">(</span><span class="NAME">fields</span><span class="PUNC">[</span><span class="NAME">opensocial.Message.Field.BODY</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>463</span> </span><span class="WHIT">                                       </span><span class="NAME">fields</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>464</span> 
<span class='line'>465</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">type</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.Activity</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>466</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">flatItems</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">fields</span><span class="PUNC">[</span><span class="NAME">opensocial.Activity.Field.MEDIA_ITEMS</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>467</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">me.isArray</span><span class="PUNC">(</span><span class="NAME">flatItems</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>468</span> </span><span class="WHIT">            </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">richItems</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>469</span> </span><span class="WHIT">            </span><span class="NAME">me.forEach</span><span class="PUNC">(</span><span class="NAME">flatItems</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>470</span> </span><span class="WHIT">              </span><span class="NAME">richItems.push</span><span class="PUNC">(</span><span class="NAME">me.unwrapObject</span><span class="PUNC">(</span><span class="NAME">item</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opensocial.MediaItem</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>471</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>472</span> </span><span class="WHIT">            </span><span class="NAME">fields</span><span class="PUNC">[</span><span class="NAME">opensocial.Activity.Field.MEDIA_ITEMS</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">richItems</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>473</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>474</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opensocial.newActivity</span><span class="PUNC">(</span><span class="NAME">fields</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>475</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>476</span> 
<span class='line'>477</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>478</span> </span><span class="WHIT">      </span><span class="COMM">// If reaches here, codes are wrong.</span><span class="WHIT">
<span class='line'>479</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">e</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">Error</span><span class="PUNC">(</span><span class="STRN">'The object does not has fields values or type mismatched.'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>480</span> </span><span class="WHIT">      </span><span class="NAME">e</span><span class="PUNC">[</span><span class="STRN">'name'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">"OpensocialError"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>481</span> </span><span class="WHIT">      </span><span class="KEYW">throw</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>482</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>483</span> 
<span class='line'>484</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>485</span>      * When any data request error happens, log down the error and callback to swf.
<span class='line'>486</span>      * @param {string} reqID The request ID.
<span class='line'>487</span>      * @param {Error} error The error thrown during the response.
<span class='line'>488</span>      * @private
<span class='line'>489</span>      */</span><span class="WHIT">
<span class='line'>490</span> </span><span class="WHIT">    </span><span class="NAME">me.handleError</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">error</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>491</span> </span><span class="WHIT">      </span><span class="NAME">INFO</span><span class="PUNC">(</span><span class="NAME">error</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>492</span> </span><span class="WHIT">      </span><span class="NAME">me.swfObj.handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">error</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>493</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>494</span> 
<span class='line'>495</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>496</span>      * When any data request error happens, log down the error and callback to swf.
<span class='line'>497</span>      * @param {string} reqID The request ID.
<span class='line'>498</span>      * @param {Object?} opt_data Some data to pass back
<span class='line'>499</span>      * @private
<span class='line'>500</span>      */</span><span class="WHIT">
<span class='line'>501</span> </span><span class="WHIT">    </span><span class="NAME">me.handleAsync</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_data</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>502</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">args</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>503</span> </span><span class="WHIT">      </span><span class="NAME">me.forEach</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">arg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>504</span> </span><span class="WHIT">        </span><span class="NAME">args.push</span><span class="PUNC">(</span><span class="NAME">arg</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>505</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>506</span> </span><span class="WHIT">      </span><span class="NAME">me.swfObj.handleAsync.apply</span><span class="PUNC">(</span><span class="NAME">me.swfObj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">args</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>507</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>508</span> 
<span class='line'>509</span> 
<span class='line'>510</span> </span><span class="WHIT">    </span><span class="COMM">//======================== Opensocial Rpc Helper Functions (private) ==========================</span><span class="WHIT">
<span class='line'>511</span> 
<span class='line'>512</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>513</span>      * Stores the running rpc instances.
<span class='line'>514</span>      * @private
<span class='line'>515</span>      */</span><span class="WHIT">
<span class='line'>516</span> </span><span class="WHIT">    </span><span class="NAME">me.rpcStore</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>517</span> 
<span class='line'>518</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>519</span>      * Pushes the running rpc instance to the store and returns an unique callID. It is used by
<span class='line'>520</span>      * asynchronous rpc register service.
<span class='line'>521</span>      * @param {Object} rpc The rpc instance defined in &lt;code>gadgets.rpc&lt;/code>.
<span class='line'>522</span>      * @return {string} The callID.
<span class='line'>523</span>      * @private
<span class='line'>524</span>      */</span><span class="WHIT">
<span class='line'>525</span> </span><span class="WHIT">    </span><span class="NAME">me.pushRpc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">rpc</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>526</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">callID</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">rpc.s</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'_'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">String</span><span class="PUNC">(</span><span class="NAME">rpc.c</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">  </span><span class="COMM">// 'your-service-name_#'</span><span class="WHIT">
<span class='line'>527</span> </span><span class="WHIT">      </span><span class="NAME">me.rpcStore</span><span class="PUNC">[</span><span class="NAME">callID</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">rpc</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>528</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">callID</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>529</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>530</span> 
<span class='line'>531</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>532</span>      * Pops the running rpc instance from the store with the callID. It is used by
<span class='line'>533</span>      * asynchronous rpc register service.
<span class='line'>534</span>      * @param {string} callID The callID of the rpc instance to be popped and removed.
<span class='line'>535</span>      * @return {Object} The rpc instance defined in &lt;code>gadgets.rpc&lt;/code>.
<span class='line'>536</span>      * @private
<span class='line'>537</span>      */</span><span class="WHIT">
<span class='line'>538</span> </span><span class="WHIT">    </span><span class="NAME">me.popRpc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">callID</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>539</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">rpc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.rpcStore</span><span class="PUNC">[</span><span class="NAME">callID</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>540</span> </span><span class="WHIT">      </span><span class="KEYW">delete</span><span class="WHIT"> </span><span class="NAME">me.rpcStore</span><span class="PUNC">[</span><span class="NAME">callID</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>541</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">rpc</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>542</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>543</span> 
<span class='line'>544</span> </span><span class="WHIT">    </span><span class="COMM">//======================== Legacy Translators ================================================</span><span class="WHIT">
<span class='line'>545</span> </span><span class="WHIT">    </span><span class="COMM">// These translators is translating the osapi-options to DataRequest params. They will be</span><span class="WHIT">
<span class='line'>546</span> </span><span class="WHIT">    </span><span class="COMM">// deprecated when the osapi part is really using osapi. Currently it is still a wrapper of</span><span class="WHIT">
<span class='line'>547</span> </span><span class="WHIT">    </span><span class="COMM">// DataRequest.</span><span class="WHIT">
<span class='line'>548</span> </span><span class="WHIT">    </span><span class="COMM">// See also in this file:</span><span class="WHIT">
<span class='line'>549</span> </span><span class="WHIT">    </span><span class="COMM">//     opensocial.flash.people.*</span><span class="WHIT">
<span class='line'>550</span> </span><span class="WHIT">    </span><span class="COMM">//     opensocial.flash.activity.*</span><span class="WHIT">
<span class='line'>551</span> </span><span class="WHIT">    </span><span class="COMM">//     opensocial.flash.appdata.*</span><span class="WHIT">
<span class='line'>552</span> 
<span class='line'>553</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>554</span>      * Translates the osapi-options to people request params.
<span class='line'>555</span>      * @param {Object} options The unwrapped options object of type PeopleRequestOptions.
<span class='line'>556</span>      * @return {Object} The DataRequest preferred parameters map.
<span class='line'>557</span>      * @private
<span class='line'>558</span>      */</span><span class="WHIT">
<span class='line'>559</span> </span><span class="WHIT">    </span><span class="NAME">me.translatePeopleRequestParams</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>560</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>561</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">fieldNames</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.DataRequest.PeopleRequestFields</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>562</span> </span><span class="WHIT">      </span><span class="NAME">params</span><span class="PUNC">[</span><span class="NAME">fieldNames.MAX</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'count'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">20</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>563</span> </span><span class="WHIT">      </span><span class="NAME">params</span><span class="PUNC">[</span><span class="NAME">fieldNames.FIRST</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'startIndex'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>564</span> </span><span class="WHIT">      </span><span class="NAME">params</span><span class="PUNC">[</span><span class="NAME">fieldNames.SORT_ORDER</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'sortBy'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>565</span> </span><span class="WHIT">      </span><span class="NAME">params</span><span class="PUNC">[</span><span class="NAME">fieldNames.FILTER</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'filterBy'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>566</span> </span><span class="WHIT">      </span><span class="NAME">params</span><span class="PUNC">[</span><span class="NAME">fieldNames.PROFILE_DETAILS</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'fields'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>567</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">params</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>568</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>569</span> 
<span class='line'>570</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>571</span>      * Translates the osapi-options to activities request params.
<span class='line'>572</span>      * @param {Object} options The unwrapped options object of type ActivitiesRequestOptions.
<span class='line'>573</span>      * @return {Object} The DataRequest preferred parameters map.
<span class='line'>574</span>      * @private
<span class='line'>575</span>      */</span><span class="WHIT">
<span class='line'>576</span> </span><span class="WHIT">    </span><span class="NAME">me.translateActivityRequestParams</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>577</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>578</span> </span><span class="WHIT">      </span><span class="COMM">// var fieldNames = opensocial.DataRequest.ActivityRequestFields;</span><span class="WHIT">
<span class='line'>579</span> </span><span class="WHIT">      </span><span class="NAME">params</span><span class="PUNC">[</span><span class="STRN">'max'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'count'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">20</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>580</span> </span><span class="WHIT">      </span><span class="NAME">params</span><span class="PUNC">[</span><span class="STRN">'first'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'startIndex'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>581</span> </span><span class="WHIT">      </span><span class="NAME">params</span><span class="PUNC">[</span><span class="STRN">'appId'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'appId'</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="STRN">'@app'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>582</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">params</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>583</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>584</span> 
<span class='line'>585</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>586</span>      * Translates the ids from osapi-options style to request params style.
<span class='line'>587</span>      * @param {string | Array.&lt;string>} ids The ids.
<span class='line'>588</span>      * @return {string | Array.&lt;string>} The translated ids.
<span class='line'>589</span>      * @private
<span class='line'>590</span>      */</span><span class="WHIT">
<span class='line'>591</span> </span><span class="WHIT">    </span><span class="NAME">me.translateIds</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">ids</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>592</span> </span><span class="WHIT">      </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">me.isArray</span><span class="PUNC">(</span><span class="NAME">ids</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>593</span> </span><span class="WHIT">        </span><span class="NAME">ids</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">ids</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>594</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>595</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">translated</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>596</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ids.length</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>597</span> </span><span class="WHIT">      </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="NAME">i</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">len</span><span class="PUNC">;</span><span class="WHIT"> </span><span class="PUNC">++</span><span class="NAME">i</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>598</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ids</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'@viewer'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">ids</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'@me'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>599</span> </span><span class="WHIT">          </span><span class="NAME">translated</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.IdSpec.PersonId.VIEWER</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>600</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ids</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'@owner'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>601</span> </span><span class="WHIT">          </span><span class="NAME">translated</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.IdSpec.PersonId.OWNER</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>602</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ids</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'@friends'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>603</span> </span><span class="WHIT">          </span><span class="NAME">translated</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.IdSpec.GroupId.FRIENDS</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>604</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">ids</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'@self'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>605</span> </span><span class="WHIT">          </span><span class="NAME">translated</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.IdSpec.GroupId.SELF</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>606</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>607</span> </span><span class="WHIT">          </span><span class="NAME">translated</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">ids</span><span class="PUNC">[</span><span class="NAME">i</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>608</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>609</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>610</span> </span><span class="WHIT">      </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">len</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NUMB">1</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">translated</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">translated</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>611</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>612</span> 
<span class='line'>613</span> </span><span class="WHIT">    </span><span class="COMM">/**
<span class='line'>614</span>      * Translates the user and group information in osapi-options to an IdSpec object.
<span class='line'>615</span>      * @param {Object} options The unwrapped options object of any subtypes of RequestOptions.
<span class='line'>616</span>      * @return {Object} The IdSpec object.
<span class='line'>617</span>      * @private
<span class='line'>618</span>      */</span><span class="WHIT">
<span class='line'>619</span> </span><span class="WHIT">    </span><span class="NAME">me.translateIdSpec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>620</span> </span><span class="WHIT">      </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">userId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'userId'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>621</span> </span><span class="WHIT">      </span><span class="NAME">userId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.translateIds</span><span class="PUNC">(</span><span class="NAME">userId</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>622</span> </span><span class="WHIT">      
<span class='line'>623</span>       </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">groupId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'groupId'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>624</span> </span><span class="WHIT">      </span><span class="NAME">groupId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.translateIds</span><span class="PUNC">(</span><span class="NAME">groupId</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>625</span> </span><span class="WHIT">      
<span class='line'>626</span>       </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opensocial.newIdSpec</span><span class="PUNC">(</span><span class="PUNC">{</span><span class="STRN">'userId'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">userId</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>627</span> </span><span class="WHIT">                                   </span><span class="STRN">'groupId'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">groupId</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>628</span> </span><span class="WHIT">                                   </span><span class="STRN">'networkDistance'</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'networkDistance'</span><span class="PUNC">]</span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>629</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>630</span> 
<span class='line'>631</span> 
<span class='line'>632</span> </span><span class="WHIT">    </span><span class="COMM">//======================== Public API functions ================================================</span><span class="WHIT">
<span class='line'>633</span> 
<span class='line'>634</span> </span><span class="WHIT">    </span><span class="NAME">me.api</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="COMM">/** @scope opensocial.flash */</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>635</span> 
<span class='line'>636</span> </span><span class="WHIT">      </span><span class="COMM">//======================== Flash Embeded Object Functions ====================================</span><span class="WHIT">
<span class='line'>637</span> </span><span class="WHIT">      </span><span class="COMM">/**
<span class='line'>638</span>        * Indicates if the opensocial library is loaded and initialize the flash element.
<span class='line'>639</span>        * &lt;p>
<span class='line'>640</span>        * The objectId of the swf is defined in gagdet spec. If the swf is embeded by calling
<span class='line'>641</span>        * &lt;code>opensocial.flash.embedFlash&lt;/code> function, the detault objectId will be 'flashObj'.
<span class='line'>642</span>        * &lt;/p>&lt;p>
<span class='line'>643</span>        * This function is called by the swf's &lt;code>ExternalInterface&lt;/code> continuingly until it
<span class='line'>644</span>        * returns true.
<span class='line'>645</span>        * &lt;/p>
<span class='line'>646</span>        *
<span class='line'>647</span>        * @param {string?} objectId The object Id passed from the swf.
<span class='line'>648</span>        * @return {boolean} true if all javascripts are loaded.
<span class='line'>649</span>        *
<span class='line'>650</span>        * @member opensocial.flash
<span class='line'>651</span>        */</span><span class="WHIT">
<span class='line'>652</span> </span><span class="WHIT">      </span><span class="NAME">jsReady</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">objectId</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>653</span> </span><span class="WHIT">        </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>654</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">me.swfObj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>655</span> </span><span class="WHIT">            </span><span class="NAME">me.swfObj</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.thisMovie</span><span class="PUNC">(</span><span class="NAME">objectId</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>656</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>657</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="PUNC">!</span><span class="PUNC">!</span><span class="NAME">me.swfObj</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>658</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>659</span> </span><span class="WHIT">          </span><span class="NAME">INFO</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>660</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>661</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>662</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>663</span> 
<span class='line'>664</span> </span><span class="WHIT">      </span><span class="COMM">/**
<span class='line'>665</span>        * Because &lt;code>gadgets.flash.embedFlash&lt;/code> cannot auto activate it in IE6, so here we
<span class='line'>666</span>        * need a special one.
<span class='line'>667</span>        * &lt;p>
<span class='line'>668</span>        * NOTE: to be deprecated.
<span class='line'>669</span>        * &lt;/p>
<span class='line'>670</span>        *
<span class='line'>671</span>        * @requires gadgets.flash
<span class='line'>672</span>        *
<span class='line'>673</span>        * @param {string} swfUrl  The swf file's location.
<span class='line'>674</span>        * @param {string} swfContainer  The HTML element id.
<span class='line'>675</span>        * @param {string?} opt_playerVersion Required flash player version.
<span class='line'>676</span>        * @param {Object.&lt;string, string>?} opt_params Flash object's parameters.
<span class='line'>677</span>        * @param {string?} opt_upgradeMsgHTML The message if the flashplayer version is too old.
<span class='line'>678</span>        * @return {boolean} True if the flash object is successfully embeded.
<span class='line'>679</span>        *
<span class='line'>680</span>        * @member opensocial.flash
<span class='line'>681</span>        */</span><span class="WHIT">
<span class='line'>682</span> </span><span class="WHIT">      </span><span class="NAME">embedFlash</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">swfUrl</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">swfContainer</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>683</span> </span><span class="WHIT">                            </span><span class="NAME">opt_playerVersion</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_upgradeMsgHTML</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>684</span> 
<span class='line'>685</span> </span><span class="WHIT">        </span><span class="NAME">opt_params</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>686</span> 
<span class='line'>687</span> </span><span class="WHIT">        </span><span class="COMM">// Check container element</span><span class="WHIT">
<span class='line'>688</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">container</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.thisDoc</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getElementById</span><span class="PUNC">(</span><span class="NAME">swfContainer</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>689</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="PUNC">!</span><span class="NAME">container</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>690</span> 
<span class='line'>691</span> </span><span class="WHIT">        </span><span class="COMM">// Check version</span><span class="WHIT">
<span class='line'>692</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">version</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_playerVersion.match</span><span class="PUNC">(</span><span class="REGX">/(\d+)(?=[\.,]?)/g</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>693</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">expectMajorVer</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">version</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="NAME">Number</span><span class="PUNC">(</span><span class="NAME">version</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NUMB">9</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>694</span> 
<span class='line'>695</span> </span><span class="WHIT">        </span><span class="NAME">EXPORT</span><span class="PUNC">(</span><span class="STRN">"PLAYER_CURRENT_VER"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">gadgets.flash.getMajorVersion</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>696</span> </span><span class="WHIT">        </span><span class="NAME">EXPORT</span><span class="PUNC">(</span><span class="STRN">"PLAYER_EXPECED_VER"</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">expectMajorVer</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>697</span> 
<span class='line'>698</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">gadgets.flash.getMajorVersion</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">&lt;</span><span class="WHIT"> </span><span class="NAME">expectMajorVer</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>699</span> </span><span class="WHIT">          </span><span class="NAME">opt_upgradeMsgHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_upgradeMsgHTML</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT">
<span class='line'>700</span> </span><span class="WHIT">              </span><span class="STRN">'&lt;span style="font-size:small;color:#777;"> '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>701</span> </span><span class="WHIT">              </span><span class="STRN">'Please install or upgrade to '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>702</span> </span><span class="WHIT">              </span><span class="STRN">'&lt;a href="http://www.adobe.com/cn/products/flashplayer/" '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>703</span> </span><span class="WHIT">              </span><span class="STRN">'style="color:#36C;" target="_blank">Flash Player 9.0&lt;/a>.&lt;/span>'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>704</span> </span><span class="WHIT">          </span><span class="NAME">container.innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_upgradeMsgHTML</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>705</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">false</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>706</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>707</span> 
<span class='line'>708</span> </span><span class="WHIT">        </span><span class="COMM">/*
<span class='line'>709</span>         opt_params['id'] = me.DEFAULT_FLASH_ID;
<span class='line'>710</span>         opt_params['name'] = me.DEFAULT_FLASH_ID;
<span class='line'>711</span>         return gadgets.flash.embedFlash(swfUrl, container, version, opt_params);
<span class='line'>712</span>         */</span><span class="WHIT">
<span class='line'>713</span> </span><span class="WHIT">        </span><span class="COMM">// Generate the flash object element</span><span class="WHIT">
<span class='line'>714</span> </span><span class="WHIT">        </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">""</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>715</span> </span><span class="WHIT">        </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">me.thisBrowser</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">plugins</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>716</span> </span><span class="WHIT">            </span><span class="NAME">me.thisBrowser</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">mimeTypes</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT">
<span class='line'>717</span> </span><span class="WHIT">            </span><span class="NAME">me.thisBrowser</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">mimeTypes.length</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>718</span> </span><span class="WHIT">          </span><span class="COMM">// netscape plugin architecture</span><span class="WHIT">
<span class='line'>719</span> </span><span class="WHIT">          </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'&lt;embed src="'</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">swfUrl</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>720</span> </span><span class="WHIT">                 </span><span class="STRN">'" id="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">me.DEFAULT_FLASH_ID</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>721</span> </span><span class="WHIT">                 </span><span class="STRN">'" name="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">me.DEFAULT_FLASH_ID</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>722</span> </span><span class="WHIT">                 </span><span class="STRN">'" type="application/x-shockwave-flash"'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>723</span> </span><span class="WHIT">          </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">)</span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>724</span> </span><span class="WHIT">            </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'="'</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'" '</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>725</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>726</span> </span><span class="WHIT">          </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'/>'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>727</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>728</span> </span><span class="WHIT">          </span><span class="COMM">// PC IE</span><span class="WHIT">
<span class='line'>729</span> </span><span class="WHIT">          </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'&lt;object id="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">me.DEFAULT_FLASH_ID</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT">
<span class='line'>730</span> </span><span class="WHIT">                 </span><span class="STRN">'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>731</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'&lt;param name="movie" value="'</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">swfUrl</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'" />'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>732</span> </span><span class="WHIT">          </span><span class="KEYW">for</span><span class="PUNC">(</span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>733</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'width'</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="STRN">'height'</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>734</span> </span><span class="WHIT">              </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">' '</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'="'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">'"'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>735</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>736</span> </span><span class="WHIT">              </span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'&lt;param name="'</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">key</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'" value="'</span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="STRN">'" />'</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>737</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>738</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>739</span> </span><span class="WHIT">          </span><span class="NAME">html</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="PUNC">=</span><span class="WHIT"> </span><span class="STRN">'>'</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">+</span><span class="WHIT"> </span><span class="STRN">"&lt;/object>"</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>740</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>741</span> </span><span class="WHIT">        </span><span class="NAME">container.innerHTML</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">html</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>742</span> 
<span class='line'>743</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>744</span> 
<span class='line'>745</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>746</span> 
<span class='line'>747</span> </span><span class="WHIT">      </span><span class="COMM">/**
<span class='line'>748</span>        * Get the swf object.
<span class='line'>749</span>        * @param {string?} opt_name The object/embed tag's id or name
<span class='line'>750</span>        * @return {HTMLElement} the swf object.
<span class='line'>751</span>        * @member opensocial.flash
<span class='line'>752</span>        */</span><span class="WHIT">
<span class='line'>753</span> </span><span class="WHIT">      </span><span class="NAME">getFlash</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">opt_name</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>754</span> </span><span class="WHIT">        </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">me.thisMovie</span><span class="PUNC">(</span><span class="NAME">opt_name</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>755</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>756</span> 
<span class='line'>757</span> </span><span class="WHIT">      </span><span class="COMM">//======================== Environment Wrapped Accessors ===========================</span><span class="WHIT">
<span class='line'>758</span> </span><span class="WHIT">      </span><span class="COMM">/**
<span class='line'>759</span>        * OpenSocial environment module.
<span class='line'>760</span>        * @namespace Namespace for environment api functions.
<span class='line'>761</span>        * @name opensocial.flash.env
<span class='line'>762</span>        */</span><span class="WHIT">
<span class='line'>763</span> </span><span class="WHIT">      </span><span class="NAME">env</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="COMM">/** @scope opensocial.flash.env */</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>764</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>765</span>          * Check if the field is supported in the object type.
<span class='line'>766</span>          * @param {opensocial.Environment.ObjectType | string} objectType The enum name of the type.
<span class='line'>767</span>          * @param {string} The enum name of the field, defined in opensocial.XXXX.Field enums.
<span class='line'>768</span>          * @return {boolean} True if supported.
<span class='line'>769</span>          * @member opensocial.flash.env
<span class='line'>770</span>          */</span><span class="WHIT">
<span class='line'>771</span> </span><span class="WHIT">        </span><span class="NAME">supportsField</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">objectType</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">field</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>772</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opensocial.getEnvironment</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">supportsField</span><span class="PUNC">(</span><span class="NAME">objectType</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">field</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>773</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>774</span> 
<span class='line'>775</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>776</span>          * Returns the domain from environment instance.
<span class='line'>777</span>          * @return {string} The domain.
<span class='line'>778</span>          * @member opensocial.flash.env
<span class='line'>779</span>          */</span><span class="WHIT">
<span class='line'>780</span> </span><span class="WHIT">        </span><span class="NAME">getDomain</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>781</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">opensocial.getEnvironment</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getDomain</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>782</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>783</span> 
<span class='line'>784</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>785</span>          * Returns the domain from the referer.
<span class='line'>786</span>          * @return {string} The domain.
<span class='line'>787</span>          * @member opensocial.flash.env
<span class='line'>788</span>          */</span><span class="WHIT">
<span class='line'>789</span> </span><span class="WHIT">        </span><span class="NAME">getContainerDomain</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>790</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">pattern</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="REGX">/(\w+):\/\/([\w.]+)(:\d+)?\/(\S*)/</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>791</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.thisDoc</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">referrer.match</span><span class="PUNC">(</span><span class="NAME">pattern</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>792</span> </span><span class="WHIT">          </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">result</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="WHIT"> </span><span class="PUNC">?</span><span class="WHIT"> </span><span class="STRN">''</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="NAME">result</span><span class="PUNC">[</span><span class="NUMB">2</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>793</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>794</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>795</span> 
<span class='line'>796</span> </span><span class="WHIT">      </span><span class="COMM">//======================== Gadgets Views ===========================</span><span class="WHIT">
<span class='line'>797</span> </span><span class="WHIT">      </span><span class="COMM">/**
<span class='line'>798</span>        * Gadgets views module.
<span class='line'>799</span>        * @namespace Namespace for view api functions.
<span class='line'>800</span>        * @name opensocial.flash.views
<span class='line'>801</span>        */</span><span class="WHIT">
<span class='line'>802</span> </span><span class="WHIT">      </span><span class="NAME">views</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="COMM">/** @scope opensocial.flash.views */</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>803</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>804</span>          * Returns the name of the in gadgets.views static class.
<span class='line'>805</span>          * @requires gadgets.views
<span class='line'>806</span>          * @return {gadgets.views.ViewType | string} The view name.
<span class='line'>807</span>          * @member opensocial.flash.views
<span class='line'>808</span>          */</span><span class="WHIT">
<span class='line'>809</span> </span><span class="WHIT">        </span><span class="NAME">getCurrentView</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>810</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">gadgets</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">gadgets.views</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>811</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">gadgets.views.getCurrentView</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">getName</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>812</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>813</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>814</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>815</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>816</span> 
<span class='line'>817</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>818</span>          * Returns the parameters passed into this gadget for this view.
<span class='line'>819</span>          * @requires gadgets.views
<span class='line'>820</span>          * @return {Object.&lt;string, string>} The param object.
<span class='line'>821</span>          * @member opensocial.flash.views
<span class='line'>822</span>          */</span><span class="WHIT">
<span class='line'>823</span> </span><span class="WHIT">        </span><span class="NAME">getViewParams</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>824</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">gadgets</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">gadgets.views</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>825</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">gadgets.views.getParams</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>826</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>827</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>828</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>829</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>830</span> 
<span class='line'>831</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>832</span>          * Indicates if the app is only one gadget on the page or not.
<span class='line'>833</span>          * @requires gadget.views
<span class='line'>834</span>          * @return {Boolean} True if it's the only one gadget.
<span class='line'>835</span>          * @member opensocial.flash.views
<span class='line'>836</span>          */</span><span class="WHIT">
<span class='line'>837</span> </span><span class="WHIT">        </span><span class="NAME">isOnlyVisible</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>838</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">gadgets</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">gadgets.views</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>839</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="NAME">gadgets.views.getCurrentView</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">isOnlyVisibleGadget</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>840</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>841</span> </span><span class="WHIT">            </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">true</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>842</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>843</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>844</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>845</span> 
<span class='line'>846</span> </span><span class="WHIT">      </span><span class="COMM">//======================== Gadgets Window ===========================</span><span class="WHIT">
<span class='line'>847</span> </span><span class="WHIT">      </span><span class="COMM">/**
<span class='line'>848</span>        * Gadgets window module.
<span class='line'>849</span>        * @namespace Namespace for window api functions.
<span class='line'>850</span>        * @name opensocial.flash.win
<span class='line'>851</span>        */</span><span class="WHIT">
<span class='line'>852</span> </span><span class="WHIT">      </span><span class="NAME">win</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="COMM">/** @scope opensocial.flash.win */</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>853</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>854</span>          * Sets the width for the flash stage. It is very usefull for dynamic loading and view
<span class='line'>855</span>          * switching.
<span class='line'>856</span>          * @param {number} newWidth New width (in pixel) to be applied.
<span class='line'>857</span>          * @member opensocial.flash.win
<span class='line'>858</span>          */</span><span class="WHIT">
<span class='line'>859</span> </span><span class="WHIT">        </span><span class="NAME">setStageWidth</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">newWidth</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>860</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">me.swfObj.width</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">newWidth</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>861</span> </span><span class="WHIT">            </span><span class="NAME">me.swfObj.width</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newWidth</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>862</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>863</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>864</span> 
<span class='line'>865</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>866</span>          * Sets the height for the flash stage. It is very usefull for dynamic loading and view
<span class='line'>867</span>          * switching.
<span class='line'>868</span>          * @requires gadgets.window
<span class='line'>869</span>          * @param {number} newHeight New height (in pixel) to be applied.
<span class='line'>870</span>          * @member opensocial.flash.win
<span class='line'>871</span>          */</span><span class="WHIT">
<span class='line'>872</span> </span><span class="WHIT">        </span><span class="NAME">setStageHeight</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">newHeight</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>873</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">me.swfObj.height</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="NAME">newHeight</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>874</span> </span><span class="WHIT">            </span><span class="NAME">me.swfObj.height</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">newHeight</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>875</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">gadgets</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">gadgets.window</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">gadgets.window.adjustHeight</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>876</span> </span><span class="WHIT">              </span><span class="NAME">gadgets.window.adjustHeight</span><span class="PUNC">(</span><span class="NAME">newHeight</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>877</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>878</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>879</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>880</span> 
<span class='line'>881</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>882</span>          * Sets the title of this app.
<span class='line'>883</span>          * @requires gadgets.window
<span class='line'>884</span>          * @param {string} newTitle New title to be applied.
<span class='line'>885</span>          * @member opensocial.flash.win
<span class='line'>886</span>          */</span><span class="WHIT">
<span class='line'>887</span> </span><span class="WHIT">        </span><span class="NAME">setTitle</span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">newTitle</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>888</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">gadgets</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">gadgets.window</span><span class="WHIT"> </span><span class="PUNC">&&</span><span class="WHIT"> </span><span class="NAME">gadgets.window.setTitle</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>889</span> </span><span class="WHIT">            </span><span class="NAME">gadgets.window.setTitle</span><span class="PUNC">(</span><span class="NAME">newTitle</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>890</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>891</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>892</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>893</span> 
<span class='line'>894</span> </span><span class="WHIT">      </span><span class="COMM">//======================== Gadgets RPC ===========================</span><span class="WHIT">
<span class='line'>895</span> </span><span class="WHIT">      </span><span class="COMM">/**
<span class='line'>896</span>        * Gadgets rpc module.
<span class='line'>897</span>        * @namespace Namespace for rpc api functions.
<span class='line'>898</span>        * @name opensocial.flash.rpc
<span class='line'>899</span>        */</span><span class="WHIT">
<span class='line'>900</span> </span><span class="WHIT">      </span><span class="NAME">rpc</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="COMM">/** @scope opensocial.flash.rpc */</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>901</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>902</span>          * Sends the rpc call request to a service on another app or container on the page.
<span class='line'>903</span>          *
<span class='line'>904</span>          * @param {string} reqID The request id.
<span class='line'>905</span>          * @param {string?} targetId The target app id, null to call the parent.
<span class='line'>906</span>          * @param {string} serviceName The service name registered on the target.
<span class='line'>907</span>          * @param {Array.&lt;Object>?} argsArray The array of args to be passed to the service.
<span class='line'>908</span>          * @member opensocial.flash.rpc
<span class='line'>909</span>          */</span><span class="WHIT">
<span class='line'>910</span> </span><span class="WHIT">        </span><span class="NAME">call</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">targetId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">serviceName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">argsArray</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>911</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">reqArgs</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">targetId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">serviceName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>912</span> </span><span class="WHIT">            </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">arguments.length</span><span class="WHIT"> </span><span class="PUNC">></span><span class="WHIT"> </span><span class="NUMB">0</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>913</span> </span><span class="WHIT">              </span><span class="NAME">me.handleAsync</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">arguments</span><span class="PUNC">[</span><span class="NUMB">0</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>914</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>915</span> </span><span class="WHIT">              </span><span class="NAME">me.handleAsync</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>916</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>917</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>918</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">argsArray</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>919</span> </span><span class="WHIT">            </span><span class="NAME">me.forEach</span><span class="PUNC">(</span><span class="NAME">argsArray</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">arg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>920</span> </span><span class="WHIT">              </span><span class="NAME">reqArgs.push</span><span class="PUNC">(</span><span class="NAME">arg</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>921</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>922</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>923</span> </span><span class="WHIT">          </span><span class="NAME">gadgets.rpc.call.apply</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">reqArgs</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>924</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>925</span> 
<span class='line'>926</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>927</span>          * Sends the return value to to last received rpc service back to the caller app. Only
<span class='line'>928</span>          * callback if the returnValue is available.
<span class='line'>929</span>          * @param {string} callID The call id for the rpc called by the caller app.
<span class='line'>930</span>          * @param {Object?} opt_returnValue The return value of the rpc service.
<span class='line'>931</span>          * @member opensocial.flash.rpc
<span class='line'>932</span>          */</span><span class="WHIT">
<span class='line'>933</span> </span><span class="WHIT">        </span><span class="NAME">serviceReturn</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">callID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_returnValue</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>934</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">rpc</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.popRpc</span><span class="PUNC">(</span><span class="NAME">callID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>935</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">opt_returnValue</span><span class="WHIT"> </span><span class="PUNC">!=</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>936</span> </span><span class="WHIT">            </span><span class="NAME">rpc.callback</span><span class="PUNC">(</span><span class="NAME">opt_returnValue</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>937</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>938</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>939</span> 
<span class='line'>940</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>941</span>          * Sends the rpc register request to container to register a service on this app.
<span class='line'>942</span>          *
<span class='line'>943</span>          * @param {string} serviceName The service to be register.
<span class='line'>944</span>          * @param {string} handlerName The handler function name on the flash object.
<span class='line'>945</span>          * @member opensocial.flash.rpc
<span class='line'>946</span>          */</span><span class="WHIT">
<span class='line'>947</span> </span><span class="WHIT">        </span><span class="NAME">serviceRegister</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">serviceName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">handlerName</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>948</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">handler</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>949</span> </span><span class="WHIT">            </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>950</span> </span><span class="WHIT">              </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">callID</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.pushRpc</span><span class="PUNC">(</span><span class="KEYW">this</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>951</span> </span><span class="WHIT">              </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">args</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="PUNC">[</span><span class="NAME">callID</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>952</span> </span><span class="WHIT">              </span><span class="NAME">me.forEach</span><span class="PUNC">(</span><span class="NAME">arguments</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">arg</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>953</span> </span><span class="WHIT">                </span><span class="NAME">args.push</span><span class="PUNC">(</span><span class="NAME">arg</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>954</span> </span><span class="WHIT">              </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>955</span> </span><span class="WHIT">              </span><span class="NAME">me.swfObj</span><span class="PUNC">[</span><span class="NAME">handlerName</span><span class="PUNC">]</span><span class="PUNC">.</span><span class="NAME">apply</span><span class="PUNC">(</span><span class="NAME">me.swfObj</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">args</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>956</span> </span><span class="WHIT">              </span><span class="COMM">// no return here, call rpcReturn in flash to return the result.</span><span class="WHIT">
<span class='line'>957</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>958</span> </span><span class="WHIT">              </span><span class="NAME">me.handleError</span><span class="PUNC">(</span><span class="KEYW">null</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>959</span> </span><span class="WHIT">              </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>960</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>961</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>962</span> 
<span class='line'>963</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">serviceName</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>964</span> </span><span class="WHIT">            </span><span class="NAME">gadgets.rpc.registerDefault</span><span class="PUNC">(</span><span class="NAME">handler</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>965</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>966</span> </span><span class="WHIT">            </span><span class="NAME">gadgets.rpc.register</span><span class="PUNC">(</span><span class="NAME">serviceName</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">handler</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>967</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>968</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>969</span> 
<span class='line'>970</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>971</span>          * Sends the rpc unregister request to container.
<span class='line'>972</span>          *
<span class='line'>973</span>          * @param {string} serviceName The service to be unregister.
<span class='line'>974</span>          * @member opensocial.flash.rpc
<span class='line'>975</span>          */</span><span class="WHIT">
<span class='line'>976</span> </span><span class="WHIT">        </span><span class="NAME">serviceUnregister</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">serviceName</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>977</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">serviceName</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="KEYW">null</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>978</span> </span><span class="WHIT">            </span><span class="NAME">gadgets.rpc.unregisterDefault</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>979</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>980</span> </span><span class="WHIT">            </span><span class="NAME">gadgets.rpc.unregister</span><span class="PUNC">(</span><span class="NAME">serviceName</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>981</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>982</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>983</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>984</span> 
<span class='line'>985</span> 
<span class='line'>986</span> </span><span class="WHIT">      </span><span class="COMM">//======================== Gadgets IO ===========================</span><span class="WHIT">
<span class='line'>987</span> </span><span class="WHIT">      </span><span class="COMM">/**
<span class='line'>988</span>        * Gadgets io module (osapi.http).
<span class='line'>989</span>        * @namespace Namespace for io api functions.
<span class='line'>990</span>        * @name opensocial.flash.io
<span class='line'>991</span>        */</span><span class="WHIT">
<span class='line'>992</span> </span><span class="WHIT">      </span><span class="NAME">io</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="COMM">/** @scope opensocial.flash.io */</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>993</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>994</span>          * Sends request to a remote site to get or post data.
<span class='line'>995</span>          *
<span class='line'>996</span>          * @param {string} reqID The request id.
<span class='line'>997</span>          * @param {string} url The remote site
<span class='line'>998</span>          * @param {Object.&lt;gadgets.io.RequestParameters, Object>?} opt_params
<span class='line'>999</span>          *            Parameters for the request
<span class='line'>1000</span>          * @member opensocial.flash.io
<span class='line'>1001</span>          */</span><span class="WHIT">
<span class='line'>1002</span> </span><span class="WHIT">        </span><span class="NAME">makeRequest</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1003</span> </span><span class="WHIT">          </span><span class="NAME">opt_params</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="WHIT"> </span><span class="PUNC">||</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1004</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">postData</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">[</span><span class="NAME">gadgets.io.RequestParameters.POST_DATA</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1005</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">postData</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1006</span> </span><span class="WHIT">            </span><span class="NAME">opt_params</span><span class="PUNC">[</span><span class="NAME">gadgets.io.RequestParameters.POST_DATA</span><span class="PUNC">]</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">gadgets.io.encodeValues</span><span class="PUNC">(</span><span class="NAME">postData</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1007</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1008</span> </span><span class="WHIT">          </span><span class="NAME">gadgets.io.makeRequest</span><span class="PUNC">(</span><span class="NAME">url</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">obj</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1009</span> </span><span class="WHIT">            </span><span class="NAME">me.handleAsync</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">obj</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1010</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opt_params</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1011</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1012</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1013</span> 
<span class='line'>1014</span> </span><span class="WHIT">      </span><span class="COMM">//======================== OSAPI ===========================</span><span class="WHIT">
<span class='line'>1015</span> </span><span class="WHIT">      </span><span class="COMM">// NOTE: Currently not all container support osapi.</span><span class="WHIT">
<span class='line'>1016</span> </span><span class="WHIT">      </span><span class="COMM">// So here all osapi will still go throw legacy 0.8 standard interfaces.</span><span class="WHIT">
<span class='line'>1017</span> </span><span class="WHIT">      </span><span class="COMM">// Once the osapi is fully supported, remove deprecated codes.</span><span class="WHIT">
<span class='line'>1018</span> </span><span class="WHIT">      </span><span class="COMM">/**
<span class='line'>1019</span>        * OpenSocial osapi people service module (osapi.people).
<span class='line'>1020</span>        * @namespace Namespace for people service functions.
<span class='line'>1021</span>        * @name opensocial.flash.people
<span class='line'>1022</span>        */</span><span class="WHIT">
<span class='line'>1023</span> </span><span class="WHIT">      </span><span class="NAME">people</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="COMM">/** @scope opensocial.flash.people */</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1024</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>1025</span>          * Sends request to a remote site to get viewer, owner or friends.
<span class='line'>1026</span>          *
<span class='line'>1027</span>          * @param {string} reqID The request id.
<span class='line'>1028</span>          * @param {Object.&lt;string, Object>?} options An object unwrapped from PeopleRequestOptions.
<span class='line'>1029</span>          * @member opensocial.flash.people
<span class='line'>1030</span>          */</span><span class="WHIT">
<span class='line'>1031</span> </span><span class="WHIT">        </span><span class="NAME">get</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1032</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.translatePeopleRequestParams</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1033</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">idSpec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.translateIdSpec</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1034</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">userId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">idSpec.getField</span><span class="PUNC">(</span><span class="NAME">opensocial.IdSpec.Field.USER_ID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1035</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">groupId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">idSpec.getField</span><span class="PUNC">(</span><span class="NAME">opensocial.IdSpec.Field.GROUP_ID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1036</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">req</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.newDataRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1037</span> 
<span class='line'>1038</span> </span><span class="WHIT">          </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">groupId</span><span class="WHIT"> </span><span class="PUNC">==</span><span class="WHIT"> </span><span class="NAME">opensocial.IdSpec.GroupId.SELF</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1039</span> </span><span class="WHIT">            </span><span class="NAME">req.add</span><span class="PUNC">(</span><span class="NAME">req.newFetchPersonRequest</span><span class="PUNC">(</span><span class="NAME">userId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">params</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'p'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1040</span> </span><span class="WHIT">            </span><span class="NAME">req.send</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1041</span> </span><span class="WHIT">              </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1042</span> </span><span class="WHIT">                </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">respPerson</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.wrapObject</span><span class="PUNC">(</span><span class="NAME">me.getData</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'p'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1043</span> </span><span class="WHIT">                </span><span class="NAME">me.handleAsync</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">respPerson</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1044</span> </span><span class="WHIT">              </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1045</span> </span><span class="WHIT">                </span><span class="NAME">me.handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1046</span> </span><span class="WHIT">              </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1047</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1048</span> 
<span class='line'>1049</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">else</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1050</span> </span><span class="WHIT">            </span><span class="NAME">req.add</span><span class="PUNC">(</span><span class="NAME">req.newFetchPeopleRequest</span><span class="PUNC">(</span><span class="NAME">idSpec</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">params</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'f'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1051</span> </span><span class="WHIT">            </span><span class="NAME">req.send</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1052</span> </span><span class="WHIT">              </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1053</span> </span><span class="WHIT">                </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">respPeople</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.wrapObject</span><span class="PUNC">(</span><span class="NAME">me.getData</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'f'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1054</span> </span><span class="WHIT">                </span><span class="NAME">me.handleAsync</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">respPeople</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1055</span> </span><span class="WHIT">              </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1056</span> </span><span class="WHIT">                </span><span class="NAME">me.handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1057</span> </span><span class="WHIT">              </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1058</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1059</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1060</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1061</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1062</span> 
<span class='line'>1063</span> </span><span class="WHIT">      </span><span class="COMM">/**
<span class='line'>1064</span>        * OpenSocial osapi activities service module (osapi.activities).
<span class='line'>1065</span>        * @namespace Namespace for activities service functions.
<span class='line'>1066</span>        * @name opensocial.flash.activities
<span class='line'>1067</span>        */</span><span class="WHIT">
<span class='line'>1068</span> </span><span class="WHIT">      </span><span class="NAME">activities</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="COMM">/** @scope opensocial.flash.activities */</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1069</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>1070</span>          * Sends request to a remote site to get activities.
<span class='line'>1071</span>          *
<span class='line'>1072</span>          * @param {string} reqID The request id.
<span class='line'>1073</span>          * @param {Object.&lt;string, Object>?} options An object unwrapped from
<span class='line'>1074</span>          *        ActivitiesRequestOptions.
<span class='line'>1075</span>          * @member opensocial.flash.activities
<span class='line'>1076</span>          */</span><span class="WHIT">
<span class='line'>1077</span> </span><span class="WHIT">        </span><span class="NAME">get</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1078</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">params</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.translateActivityRequestParams</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1079</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">idSpec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.translateIdSpec</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1080</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">req</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.newDataRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1081</span> </span><span class="WHIT">          </span><span class="NAME">req.add</span><span class="PUNC">(</span><span class="NAME">req.newFetchActivitiesRequest</span><span class="PUNC">(</span><span class="NAME">idSpec</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">params</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'a'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1082</span> </span><span class="WHIT">          </span><span class="NAME">req.send</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1083</span> </span><span class="WHIT">            </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1084</span> </span><span class="WHIT">              </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">respActivities</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.wrapObject</span><span class="PUNC">(</span><span class="NAME">me.getData</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'a'</span><span class="PUNC">)</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1085</span> </span><span class="WHIT">              </span><span class="NAME">me.handleAsync</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">respActivities</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1086</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1087</span> </span><span class="WHIT">              </span><span class="NAME">me.handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1088</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1089</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1090</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1091</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1092</span> 
<span class='line'>1093</span> </span><span class="WHIT">      </span><span class="COMM">/**
<span class='line'>1094</span>        * OpenSocial osapi appdata service module (osapi.appdata).
<span class='line'>1095</span>        * @namespace Namespace for appdata service functions.
<span class='line'>1096</span>        * @name opensocial.flash.appdata
<span class='line'>1097</span>        */</span><span class="WHIT">
<span class='line'>1098</span> </span><span class="WHIT">      </span><span class="NAME">appdata</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="COMM">/** @scope opensocial.flash.appdata */</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1099</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>1100</span>          * Sends request to remote site to get app data.
<span class='line'>1101</span>          *
<span class='line'>1102</span>          * @param {string} reqID The request id.
<span class='line'>1103</span>          * @param {Object.&lt;string, Object>?} options An object unwrapped from AppDataRequestOptions.
<span class='line'>1104</span>          * @member opensocial.flash.appdata
<span class='line'>1105</span>          */</span><span class="WHIT">
<span class='line'>1106</span> </span><span class="WHIT">        </span><span class="NAME">get</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1107</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">idSpec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.translateIdSpec</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1108</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">keys</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'keys'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1109</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">req</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.newDataRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1110</span> </span><span class="WHIT">          </span><span class="NAME">req.add</span><span class="PUNC">(</span><span class="NAME">req.newFetchPersonAppDataRequest</span><span class="PUNC">(</span><span class="NAME">idSpec</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">keys</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'d'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1111</span> </span><span class="WHIT">          </span><span class="NAME">req.send</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1112</span> </span><span class="WHIT">            </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1113</span> </span><span class="WHIT">              </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">dataSet</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.getData</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'d'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1114</span> </span><span class="WHIT">              </span><span class="COMM">//dataSet is a Object.&lt;opensocial.IdSpec.PersonId, Object.&lt;string, Object>> object.</span><span class="WHIT">
<span class='line'>1115</span> </span><span class="WHIT">              </span><span class="NAME">me.handleAsync</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">dataSet</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1116</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1117</span> </span><span class="WHIT">              </span><span class="NAME">me.handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1118</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1119</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1120</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1121</span> 
<span class='line'>1122</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>1123</span>          * Sends request to remote site to update app data.
<span class='line'>1124</span>          *
<span class='line'>1125</span>          * @param {string} reqID The request id.
<span class='line'>1126</span>          * @param {Object.&lt;string, Object>?} options An object unwrapped from AppDataRequestOptions.
<span class='line'>1127</span>          * @member opensocial.flash.appdata
<span class='line'>1128</span>          */</span><span class="WHIT">
<span class='line'>1129</span> </span><span class="WHIT">         </span><span class="NAME">update</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1130</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">idSpec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.translateIdSpec</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1131</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">userId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">idSpec.getField</span><span class="PUNC">(</span><span class="NAME">opensocial.IdSpec.Field.USER_ID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1132</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1133</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1134</span> </span><span class="WHIT">          </span><span class="KEYW">for</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">key</span><span class="WHIT"> </span><span class="KEYW">in</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'data'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1135</span> </span><span class="WHIT">            </span><span class="NAME">value</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'data'</span><span class="PUNC">]</span><span class="PUNC">[</span><span class="NAME">key</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1136</span> </span><span class="WHIT">            </span><span class="KEYW">break</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1137</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1138</span> 
<span class='line'>1139</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">req</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.newDataRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1140</span> </span><span class="WHIT">          </span><span class="NAME">req.add</span><span class="PUNC">(</span><span class="NAME">req.newUpdatePersonAppDataRequest</span><span class="PUNC">(</span><span class="NAME">userId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">key</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">value</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'u'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1141</span> </span><span class="WHIT">          </span><span class="NAME">req.send</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1142</span> </span><span class="WHIT">            </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1143</span> </span><span class="WHIT">              </span><span class="NAME">me.getData</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'u'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1144</span> </span><span class="WHIT">              </span><span class="NAME">me.handleAsync</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1145</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1146</span> </span><span class="WHIT">              </span><span class="NAME">me.handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1147</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1148</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1149</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1150</span> 
<span class='line'>1151</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>1152</span>          * Sends request to remote site to delete app data.
<span class='line'>1153</span>          *
<span class='line'>1154</span>          * @param {string} reqID The request id.
<span class='line'>1155</span>          * @param {Object.&lt;string, Object>?} options An object unwrapped from AppDataRequestOptions.
<span class='line'>1156</span>          * @member opensocial.flash.appdata
<span class='line'>1157</span>          */</span><span class="WHIT">
<span class='line'>1158</span> </span><span class="WHIT">        </span><span class="NAME">deleteData</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1159</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">idSpec</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.translateIdSpec</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1160</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">userId</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">idSpec.getField</span><span class="PUNC">(</span><span class="NAME">opensocial.IdSpec.Field.USER_ID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1161</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">keys</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'keys'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1162</span> 
<span class='line'>1163</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">req</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">opensocial.newDataRequest</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1164</span> </span><span class="WHIT">          </span><span class="NAME">req.add</span><span class="PUNC">(</span><span class="NAME">req.newRemovePersonAppDataRequest</span><span class="PUNC">(</span><span class="NAME">userId</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">keys</span><span class="PUNC">)</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'r'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1165</span> </span><span class="WHIT">          </span><span class="NAME">req.send</span><span class="PUNC">(</span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1166</span> </span><span class="WHIT">            </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1167</span> </span><span class="WHIT">              </span><span class="NAME">me.getData</span><span class="PUNC">(</span><span class="NAME">dataResponse</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="STRN">'r'</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1168</span> </span><span class="WHIT">              </span><span class="NAME">me.handleAsync</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1169</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1170</span> </span><span class="WHIT">              </span><span class="NAME">me.handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1171</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1172</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1173</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1174</span> 
<span class='line'>1175</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1176</span> 
<span class='line'>1177</span> </span><span class="WHIT">      </span><span class="COMM">/**
<span class='line'>1178</span>        * OpenSocial osapi ui service module (osapi.ui).
<span class='line'>1179</span>        * @namespace Namespace for ui service functions.
<span class='line'>1180</span>        * @name opensocial.flash.ui
<span class='line'>1181</span>        */</span><span class="WHIT">
<span class='line'>1182</span> </span><span class="WHIT">      </span><span class="NAME">ui</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="COMM">/** @scope opensocial.flash.ui */</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1183</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>1184</span>          * Sends request to remote site to request an activity creation.
<span class='line'>1185</span>          *
<span class='line'>1186</span>          * @param {string} reqID The request id.
<span class='line'>1187</span>          * @param {Object.&lt;string, Object>?} options An object unwrapped from UIRequestOptions.
<span class='line'>1188</span>          * @member opensocial.flash.ui
<span class='line'>1189</span>          */</span><span class="WHIT">
<span class='line'>1190</span> </span><span class="WHIT">        </span><span class="NAME">requestCreateActivity</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1191</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">priority</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'priority'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1192</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">activity</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.unwrapObject</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'activity'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opensocial.Activity</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1193</span> </span><span class="WHIT">          </span><span class="NAME">opensocial.requestCreateActivity</span><span class="PUNC">(</span><span class="NAME">activity</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">priority</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1194</span> </span><span class="WHIT">            </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1195</span> </span><span class="WHIT">              </span><span class="NAME">me.getDataItem</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1196</span> </span><span class="WHIT">              </span><span class="NAME">me.handleAsync</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1197</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1198</span> </span><span class="WHIT">              </span><span class="NAME">me.handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1199</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1200</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1201</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1202</span> 
<span class='line'>1203</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>1204</span>          * Sends request to remote site to request messages sending.
<span class='line'>1205</span>          *
<span class='line'>1206</span>          * @param {string} reqID The request id.
<span class='line'>1207</span>          * @param {Object.&lt;string, Object>?} options An object unwrapped from UIRequestOptions.
<span class='line'>1208</span>          * @member opensocial.flash.ui
<span class='line'>1209</span>          */</span><span class="WHIT">
<span class='line'>1210</span> </span><span class="WHIT">        </span><span class="NAME">requestSendMessage</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1211</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">recipientIds</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.translateIds</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'recipientIds'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1212</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">message</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.unwrapObject</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'message'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opensocial.Message</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1213</span> </span><span class="WHIT">          </span><span class="NAME">opensocial.requestSendMessage</span><span class="PUNC">(</span><span class="NAME">recipientIds</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">message</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1214</span> </span><span class="WHIT">            </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1215</span> </span><span class="WHIT">              </span><span class="NAME">me.getDataItem</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1216</span> </span><span class="WHIT">              </span><span class="NAME">me.handleAsync</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1217</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1218</span> </span><span class="WHIT">              </span><span class="NAME">me.handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1219</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1220</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1221</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1222</span> 
<span class='line'>1223</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>1224</span>          * Sends request to remote site to request app sharing.
<span class='line'>1225</span>          *
<span class='line'>1226</span>          * @param {string} reqID The request id.
<span class='line'>1227</span>          * @param {Object.&lt;string, Object>?} options An object unwrapped from UIRequestOptions.
<span class='line'>1228</span>          * @member opensocial.flash.ui
<span class='line'>1229</span>          */</span><span class="WHIT">
<span class='line'>1230</span> </span><span class="WHIT">        </span><span class="NAME">requestShareApp</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1231</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">recipientIds</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.translateIds</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'recipientIds'</span><span class="PUNC">]</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1232</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">reason</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.unwrapObject</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'reason'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opensocial.Message</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1233</span> </span><span class="WHIT">          </span><span class="NAME">opensocial.requestShareApp</span><span class="PUNC">(</span><span class="NAME">recipientIds</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">reason</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1234</span> </span><span class="WHIT">            </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1235</span> </span><span class="WHIT">              </span><span class="NAME">me.getDataItem</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1236</span> </span><span class="WHIT">              </span><span class="NAME">me.handleAsync</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1237</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1238</span> </span><span class="WHIT">              </span><span class="NAME">me.handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1239</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1240</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1241</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="PUNC">,</span><span class="WHIT">
<span class='line'>1242</span> 
<span class='line'>1243</span> </span><span class="WHIT">        </span><span class="COMM">/**
<span class='line'>1244</span>          * Sends request to remote site to request permission.
<span class='line'>1245</span>          *
<span class='line'>1246</span>          * @param {string} reqID The request id.
<span class='line'>1247</span>          * @param {Object.&lt;string, Object>?} options An object unwrapped from UIRequestOptions.
<span class='line'>1248</span>          * @member opensocial.flash.ui
<span class='line'>1249</span>          */</span><span class="WHIT">
<span class='line'>1250</span> </span><span class="WHIT">        </span><span class="NAME">requestPermission</span><span class="WHIT"> </span><span class="PUNC">:</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1251</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">permission</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'permission'</span><span class="PUNC">]</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1252</span> </span><span class="WHIT">          </span><span class="KEYW">var</span><span class="WHIT"> </span><span class="NAME">reason</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">me.unwrapObject</span><span class="PUNC">(</span><span class="NAME">options</span><span class="PUNC">[</span><span class="STRN">'reason'</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">opensocial.Message</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1253</span> </span><span class="WHIT">          </span><span class="NAME">opensocial.requestPermission</span><span class="PUNC">(</span><span class="PUNC">[</span><span class="NAME">permission</span><span class="PUNC">]</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">reason</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="KEYW">function</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1254</span> </span><span class="WHIT">            </span><span class="KEYW">try</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1255</span> </span><span class="WHIT">              </span><span class="NAME">me.getDataItem</span><span class="PUNC">(</span><span class="NAME">responseItem</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1256</span> </span><span class="WHIT">              </span><span class="NAME">me.handleAsync</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1257</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT"> </span><span class="KEYW">catch</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">e</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1258</span> </span><span class="WHIT">              </span><span class="NAME">me.handleError</span><span class="PUNC">(</span><span class="NAME">reqID</span><span class="PUNC">,</span><span class="WHIT"> </span><span class="NAME">e</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1259</span> </span><span class="WHIT">            </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1260</span> </span><span class="WHIT">          </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1261</span> </span><span class="WHIT">        </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1262</span> </span><span class="WHIT">      </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1263</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1264</span> 
<span class='line'>1265</span> </span><span class="WHIT">    </span><span class="KEYW">if</span><span class="WHIT"> </span><span class="PUNC">(</span><span class="NAME">TESTING</span><span class="PUNC">)</span><span class="WHIT"> </span><span class="PUNC">{</span><span class="WHIT">
<span class='line'>1266</span> </span><span class="WHIT">      </span><span class="COMM">/**
<span class='line'>1267</span>        * Only visible when testing. It exports the kernel object constructor to public.
<span class='line'>1268</span>        * @type {Function} the kernel constructor.
<span class='line'>1269</span>        * @ignore
<span class='line'>1270</span>        */</span><span class="WHIT">
<span class='line'>1271</span> </span><span class="WHIT">      </span><span class="NAME">me.api.kernel</span><span class="WHIT"> </span><span class="PUNC">=</span><span class="WHIT"> </span><span class="NAME">kernel</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1272</span> </span><span class="WHIT">    </span><span class="PUNC">}</span><span class="WHIT">
<span class='line'>1273</span> </span><span class="WHIT">  </span><span class="PUNC">}</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1274</span> 
<span class='line'>1275</span> </span><span class="WHIT">  </span><span class="COMM">// The public API functions set</span><span class="WHIT">
<span class='line'>1276</span> </span><span class="WHIT">  </span><span class="KEYW">return</span><span class="WHIT"> </span><span class="KEYW">new</span><span class="WHIT"> </span><span class="NAME">kernel</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">.</span><span class="NAME">api</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1277</span> 
<span class='line'>1278</span> </span><span class="PUNC">}</span><span class="PUNC">)</span><span class="PUNC">(</span><span class="PUNC">)</span><span class="PUNC">;</span><span class="WHIT">
<span class='line'>1279</span> 
<span class='line'>1280</span> </span></pre></body></html>